using System.Linq;
using System.Windows.Forms;

namespace FluentBinding.WinForms.Controls
{
    /// <typeparam name="E">Type of the root entity</typeparam>
    public class ComboBoxBinding<E> : ControlBinding<E>, IComboBoxBinding<E>
        where E : class
    {
        #region Constructors

        public ComboBoxBinding(BindingProxy<E> bindingProxy)
            : base(bindingProxy)
        {            
        }

        #endregion

        #region IComboBoxBinding<E> Members

        public IComboBoxSelectedItemBinding<E, P> SelectedItem<P>()
            where P : class
        {
            Property<P>("SelectedItem");

            return new ComboBoxSelectedItemBinding<E, P>(_bindingProxy,
                _bindingProxy.Controls.Cast<ComboBox>().ToArray());
        }

        #endregion
    }
}